package com.yanqu.road.server.logic.recharge.limit.activity;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.entity.mall.LimitBuyResult;
import com.yanqu.road.server.gameplayer.module.activity.zhanling.ZhanLingActivityModule;
import com.yanqu.road.server.manger.activity.zhanling.ZhanLingActivityMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.protocol.GameErrorCode;

public class ZhanLingActivityMallLimit extends BaseActivityMallLimit{
    public ZhanLingActivityMallLimit(long userId, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(userId, mallInfo, activityInfo);
    }

    @Override
    protected int activityCheck() {
        if(!ZhanLingActivityMgr.mallActivityIsInTime(mallInfo.getMallId())){
            return GameErrorCode.E_ACTIVITY_NO_IN_TIME_CANNOT_BUY;
        }
        return 0;
    }

    @Override
    public boolean isSystemUnLock() {
        return SystemOpenMgr.systemOpen(player, eSystemId.ZhanLingActivity.getValue());
    }

    @Override
    public LimitBuyResult buyCountLimit() {
        LimitBuyResult limitBuyResult = new LimitBuyResult();
        limitBuyResult.setLimitCount(1);
        return limitBuyResult;
    }

    @Override
    public int logicCheck() {
        if (!player.getModule(ZhanLingActivityModule.class).isCanBuyGiftBag(mallInfo.getMallId()).isCanBuy()) {
            return GameErrorCode.E_MALL_LIMIT_BUY;   //已购买
        }
        return 0;
    }
}
